// ============================== 导入依赖 ============================== //

import CORE from '@/CORE'
import Client from '@api/base/api/FuzzyScoreApi'

import ComClass from '@api/ComQuery'

import ListClass from '@api/base/model/FuzzyScoreReq'
import EditClass from '@api/base/model/FuzzyScoreBathReq'

import BaseClass from '@api/base/model/FuzzyScoreDto'

const CLIENT = CORE.grpcCLIENT(Client)

const COM = [ComClass, 'comQuery']
const BASE = [BaseClass, 'dto']

// ============================== 导出远程接口 ============================== //

export default {
  // —————————————————————————————— 列表 —————————————————————————————— //

  async getList(param, TIP = '查询列表') {
    const DTO = CORE.grpcDTO(ListClass, param, COM, BASE)
    const resp = await CORE.grpc(TIP, CLIENT, 'fuzzyScoreQuery', DTO)
    return [resp.comQuery.totalCount, resp.dto || []]
  },
  transList(arr) {
    return arr.filter((item) => item.groupItem !== '2000')
  },

  // —————————————————————————————— 改 —————————————————————————————— //

  transEdit(one, { state: { list } }) {
    return list
  },
  async edit(list, TIP = '修改') {
    const DTO = CORE.grpcDTO(EditClass, {}, [BaseClass, 'dtos', list])
    await CORE.grpc(TIP, CLIENT, 'fuzzyScoreUpdateBatch', DTO)
    return CORE.grpcOK(TIP)
  },
}
